<?php $this->load->view('header'); ?>
<?php
  if ($msg = $this->session->flashdata('flash_message')) {
?>
  <div class="container">
    <div class="text-center notice_confirm col-md-6 col-md-offset-3">
        <?php
        echo $msg['msg'];
        ?>
    </div>
  </div>
  
<?php
}
?>

<!--MAIN-->
<!-- Page Content -->
<div class="wrap-intro">
        <div class="container">
            <div class="row">
                <div class="app-forms-fp app-form-forget col-lg-12 col-xs-12 col-sm-12">
                  <form method="post" action="<?php echo site_url('users/forgotPassword'); ?>" class="col-lg-6 col-lg-offset-3 col-xs-6 col-xs-offset-3" id="form-forget-pwd">
                    <fieldset>
                        <legend class="text-center"><span>Forgot Password</span></legend>
                        <div class="form-group">
                          <div class="col-md-12 col-sm-12 col-xs-12">
                            <input type="text" name="email_fp" placeholder="Nhập Email" value="<?php echo set_value('username'); ?>" class="form-control input-margin" id="email_fp"/>
                          </div> 
                        </div>
                        <div class="form-group">
                        <!-- <input type="hidden" name="testtt"  value="testtt"> -->
                          <div class="col-md-12 col-sm-12 col-xs-12">
                            <input type="submit" value="<?php echo $this->lang->line('E-mail Me My Password');?>" name="forgotPassword" id="forgotPassword" class="btn btn-primary btn-lg btn-block"/>
                          </div>
                        </div>
                        <div class="warning"><?php echo form_error('username'); ?></div>
                      </fieldset>
                  </form>
                </div> <!-- app-form-login -->
            </div>

        </div>
        <!-- /.container -->
</div> <!-- wrap intro -->

<script type="text/javascript">
  $(document).ready(function(){
      $("#form-forget-pwd").validate({
          errorElement: "span", // contain the error msg in a span tag
          errorClass: 'help-block',
          onkeyup: false,
          errorPlacement: function (error, element) { // render error placement for each input type
                  if (element.attr("type") == "radio" || element.attr("type") == "checkbox") { // for chosen elements, need to insert the error after the chosen container
                      error.insertAfter($(element).closest('.form-group').children('div').children().last());
                  } else if (element.attr("name") == "dd" || element.attr("name") == "mm" || element.attr("name") == "yyyy") {
                      error.insertAfter($(element).closest('.form-group').children('div'));
                  } else {
                      error.insertAfter(element);
                      // for other inputs, just perform default behavior
                  }
          },
          highlight: function (element) {
                $(element).closest('.help-block').removeClass('valid');
                // display OK icon
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error').find('.symbol').removeClass('ok').addClass('required');
                $(element).closest('.form-group').find(".glyphicon-ok").remove();
                $(element).after("<span class='glyphicon glyphicon-remove form-control-feedback'></span>");
                // add the Bootstrap error class to the control group
          },
          unhighlight: function (element) { // revert the change done by hightlight
                $(element).closest('.form-group').removeClass('has-error');
                
                // set error class to the control group
          },
          success: function (label, element) {
                label.addClass('help-block');
                // mark the current input as valid and display OK icon
                $(element).closest('.form-group').removeClass('has-error').addClass('has-success').find('.symbol').removeClass('required').addClass('ok');
                $(element).closest('.form-group').find(".glyphicon-remove").remove();
                $(element).after("<span class='glyphicon glyphicon-ok form-control-feedback'></span>");
          },
          rules : {
            "email_fp" :{
                required : true,
                email : true,
                remote: {
                  type : "POST",
                  url : "<?php echo site_url('buyer/checkEmailIsExists');?>",
                },
            },
          },
          messages:{
                "email_fp":{
                    required : "<?php echo $this->lang->line('Email')." ".$this->lang->line('required') ?>",
                    email : "<?php echo $this->lang->line('Email')." ".$this->lang->line('valid_email'); ?>",
                    remote : "<?php echo $this->lang->line('Email')." ".$this->lang->line('not_in_system'); ?>",
                },
          },
          submitHandler:function(form){
            form.submit();
          }
      });
  });
</script>
<!--END OF MAIN-->
<?php $this->load->view('footer'); ?>